package org.lq.dlz.common;

public class Const {

	public interface ConfigFile{
		String DBCP_FILE="dbcp.properties";
	}

	public interface SESSSION_KEY{
		String LOGIN_USER = "login_user";
	}
	
	public interface OrderType{
		int PLACE_ORDER=10;//下单
		String ORDER_PREFIX="hnkj";
	}

	/**
	 * 角色
	 * *
	 * @author linne
	 *
	 */
	public interface Role{
		int ROLE_CUSTOMER = 0;//普通用户
		int ROLE_ADMIN = 1;//管理员
	}

	public interface Category{
		/**
		 * 正常
		 */
		int NORMAL_STATUS=1; //正常
		/**
		 * 废弃
		 */
		int DISCARD_STATUS=0;//废弃
	}

	/**
	 * 购物车用到的常量
	 * @author linne
	 *
	 */
	public interface Cart {

		int CHECKED = 1;//购物车被选中
		int UN_CHECKED = 0;//购物车w未选中状态

	}
	/**
	 * 订单
	 * @author linne
	 *
	 */
	public enum OrderStatusEnum{

		CANCELED(0,"取消"),
		NO_PAY(10,"未付款"),
		PAID(20,"以付款"),
		SHIPPE(40,"已发货"),
		ORDER_SUCCESS(50,"订单完成"),
		ORDER_CLOSE(60,"订单关闭")
		;

		OrderStatusEnum(int code,String value){
			this.code = code;
			this.value = value;
		}

		private int code;
		private String value;
		
		 public int getCode() {
			return code;
		}

		public void setCode(int code) {
			this.code = code;
		}

		public String getValue() {
			return value;
		}

		public void setValue(String value) {
			this.value = value;
		}

		public static OrderStatusEnum codeOf(int code){
	            for(OrderStatusEnum orderStatusEnum : values()){
	                if(orderStatusEnum.getCode() == code){
	                    return orderStatusEnum;
	                }
	            }
	            throw new RuntimeException("么有找到对应的枚举");
	        }


	}


	/**
	 * 产品状态
	 * @author linne
	 *
	 */
	public enum ProductStatusEnum{

		ON_SALE(1,"在售"),
		NEXT_LEAVE(2,"下架"),
		HOT_SALE(3,"热卖"),
		HOME_SHOW(4,"首页展示")
		;

		ProductStatusEnum(int code,String value){
			this.code = code;
			this.value = value;
		}
		private int code;
		private String value;


		public static ProductStatusEnum getProductStatusEnum(int code) {
			ProductStatusEnum enum_prom = null;
			switch (code) {
			case 1:
				enum_prom = ON_SALE;
				break;
			case 2:
				enum_prom = NEXT_LEAVE;
				break;
			case 3:
				enum_prom = HOT_SALE;
				break;
			case 4:
				enum_prom = HOME_SHOW;
				break;
			default:
				break;
			}
			
			return enum_prom;
		}

		public int getCode() {
			return code;
		}
		public void setCode(int code) {
			this.code = code;
		}
		public String getValue() {
			return value;
		}
		public void setValue(String value) {
			this.value = value;
		}
	}




}
